 var videos = [
    {
      name: '视频1',
      path: 'http://118.123.60.84:8006/sccloacms/00000005000000000001000000000205',
      poster: 'https://sctel10000.cn/wechatimages/myzonenew/hkjx.png'
    }, {
      name: '视频2',
      path: 'http://118.123.60.84:8006/sccloacms/00000005000000000001000000000206',
      poster: 'https://sctel10000.cn/wechatimages/myzonenew/tccx.png'
    }, {
      name: '视频3',
      path: 'http://118.123.60.84:8006/sccloacms/00000005000000000001000000000207',
      poster: 'https://sctel10000.cn/wechatimages/myzonenew/lldg.png'
    }
 ];
var oMain = document.getElementById('main');
var oUl = document.createElement('ul');
oMain.appendChild(oUl);

/**
 * 构建视频列表
 */
function buildDomList () {
  for(var i = 0; i < videos.length; i += 1) {
    var temp = videos[i];
    buildLi(temp.name, temp.poster, i);
  }
}

// 创建 列表单元
function buildLi (name, poster, index) {
  var oLi = document.createElement('li');
  oLi.className = 'videoItem';
  oLi.dataset.index = index;
  var oImg = document.createElement('img');
  oImg.src = poster;
  oImg.onload = function () {
    oLi.appendChild(oImg);
    var oSpan = document.createElement('span');
    oSpan.innerText = name;
    oLi.appendChild(oSpan);
    oLi.addEventListener('click', onLiClick, false);
    oUl.appendChild(oLi);
  }
}

// 点击事件
function onLiClick (e) {
  var target = e.currentTarget;
  window.location.href = window.location.href + '/' + encodeURIComponent(videos[target.dataset.index].path);
}

buildDomList();